package com.css.dzj.dzjdzqs.modules.datafromzfjg.service.impl;

import com.alibaba.fastjson.JSON;
import com.css.dzj.dzjdzqs.common.util.HttpClientUtil;
import com.css.dzj.dzjdzqs.modules.datafromzfjg.entity.JgLhjgRwfkglEntity;
import com.css.dzj.dzjdzqs.modules.datafromzfjg.mapper.LhjgRwfkglMapper;
import com.css.dzj.dzjdzqs.modules.datafromzfjg.service.JgLhjgRwsFkglSercice;
import com.css.dzj.dzjdzqs.modules.datafromzfjg.vo.JgLhjgRwsfkglVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JgLhjgRwsFkglSerciceImpl implements JgLhjgRwsFkglSercice {
    @Value("${ZFJG_URL}")
    private String zfjgUrl;
    @Autowired
    private LhjgRwfkglMapper lhjgRwfkglMapper;
    @Override
    public void addLhjgRwsGlMsg()  {
        try {
            String list = HttpClientUtil.doGet(zfjgUrl + "/generator/jglhjgrwfkgl/queryAllFkgl");
            List<JgLhjgRwsfkglVo> results = JSON.parseArray(list, JgLhjgRwsfkglVo.class);
            for (JgLhjgRwsfkglVo result : results) {
                JgLhjgRwfkglEntity jgLhjgRwfkglEntity = new JgLhjgRwfkglEntity();
                jgLhjgRwfkglEntity.setUuid(result.getUuid());
                jgLhjgRwfkglEntity.setActionCode(result.getSuperviseItemCode());
                jgLhjgRwfkglEntity.setTaskno(result.getTaskno());
                lhjgRwfkglMapper.save(jgLhjgRwfkglEntity);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
